<?php
use yii\helpers\Html;
use services\models\OrderInfoDetail;

$status     = Yii::$app->request->get('status');
$timesolt   = Yii::$app->request->get('timesolt');
?>


<?php $this->beginBlock('css');?>
<link rel="stylesheet" type="text/css" href="<?= Yii::getAlias('@static')?>/pc/liketry/css/user.css">
<?php $this->endBlock();?>
<!--表头-->
<?= $this->render('@liketry/views/layouts/header_goods.php',['top_ad_show'=>false])?>
<!-- 顶部拉幕广告&&搜索框 Start -->
<div class="header"></div>
<!-- 顶部拉幕广告&&搜索框 End -->

<!-- 主体内容 Start -->
<div class="usermain">
	<?= $this->render('@liketry/views/left/left.php') ; ?>
	<div class="main-right order">
		<div class="order-select">
			<span>我的订单</span>
			<select id="orderSelect">
			  <option value="1" <?php if($timesolt == '1') :?>selected<?php endif;?>>近三个月</option>
			  <option value="0" <?php if($timesolt == '0') :?>selected<?php endif;?>>历史记录</option>
			</select>
		</div>
		<dl class="list-title">
			<dt data-id="" class="<?php if($status == '') :?>cur<?php endif;?>">全部订单</dt>
			<dt data-id="0" class="<?php if($status == '0') :?>cur<?php endif;?>" >待付款（<em><?=$orderPay['num'] ;?></em>）</dt>
			<dt data-id="3" class="<?php if($status == '3') :?>cur<?php endif;?>">待收货（<em><?=$orderReceipt['num'] ;?></em>）</dt>
			<dt data-id="5" class="<?php if($status == '5') :?>cur<?php endif;?>">待评价（<em><?=$orderEvaluate['num'] ;?></em>）</dt>
		</dl>
        
		<dl class="list-content">
			<?php if($orderInfo) :?>
            <?php foreach ($orderInfo as $key=>$vals) :?>
			<dd data-id="<?=$vals['order_info_id'] ?>"> 
				<div class="left">
					<p class="date"><?php echo date('Y',strtotime($vals['create_time']));?> <span> <?php echo date('m',strtotime($vals['create_time']));?>/<?php echo date('d',strtotime($vals['create_time']));?></span></p>
					<p class="time"><?php echo date('H:m:s',strtotime($vals['create_time']));?></p>
					<p class="price"><?php if($vals['order_amount'] != 0) :?>¥<?=Yii::$app->formatter->asDecimal($vals['order_amount'],2)?><?php endif;?></p>
					<p class="trybean">
                        <?php if($vals['order_amount'] != 0 && $vals['try_coin'] != 0) :?>+<?php endif;?>
                        <?php if($vals['try_coin'] != 0) :?><?php echo ($vals['try_coin']);?>试豆<?php endif;?></p>
				</div>
				<div class="right">
					<i class="icon icon-order-line"></i>
					<div class="order-mes">

                        <?php if ($vals['status'] == OrderInfoDetail::$STATUS_ORDER_CREATED): ?>
                            <?php if(strtotime($vals['create_time'])- strtotime("-12 hours")>0) :?>
                                <?php if($vals['pay_status'] ==OrderInfoDetail::$PAY_STATUS_FAIL || $vals['pay_status']==OrderInfoDetail::$PAY_STATUS_WAIT) :?>
                                <a>待付款</a>
                                <?php elseif ($vals['pay_status'] == OrderInfoDetail::$PAY_STATUS_CANCEL): ?>
                                <a>已取消</a>
                                <?php endif;?>
                            <?php else :?>
                                <a>已取消</a>
                            <?php endif;?>
                        <?php elseif ($vals['status'] == OrderInfoDetail::$STATUS_PAYED): ?>
                            <a>待发货</a>
                        <?php elseif ($vals['status'] == OrderInfoDetail::$STATUS_CONFIRM): ?>
                            <a>待收货</a>
                        <?php elseif ($vals['status'] == OrderInfoDetail::$STATUS_TO_SHIP): ?>
                            <a>待收货</a>
                        <?php elseif ($vals['status'] == OrderInfoDetail::$STATUS_SIGN_IN): ?>
                            <a>待收货</a>
                        <?php elseif ($vals['status'] == OrderInfoDetail::$STATUS_ORDER_OK): ?>

                             <?php if ($vals['orderGoods']['flg'] ==  OrderInfoDetail::$STATUS_COMMENT_NO ): ?>
                            <a>待评价</a>
                            <?php else:?>
                            <a>已完成</a>
                             <?php endif; ?>
                        <?php elseif ($vals['status'] == OrderInfoDetail::$STATUS_ORDER_CANCEL): ?>
                            <a>已取消</a>
                        <?php endif; ?>

                        <a href="<?=Yii::$app->urlManager->createUrl(["order-details/order-detail",'order_info_id'=>$vals['order_info_id']]);?>" class="tracking" target="_blank">包裹跟踪</a>
						<a class="order-info">收货信息
							<span>
								
							</span>
						</a>
						<span>订单号：<em><?=$vals['order_sn'] ;?></em></span>                        
					</div>
                    <?php if ($vals['status'] == OrderInfoDetail::$STATUS_COMMENT_NO && $vals['pay_status'] ==OrderInfoDetail::$PAY_STATUS_WAIT && (strtotime($vals['create_time'])- strtotime("-2 hours"))>0): ?>
                    <p class="countdown" data-time="<?php echo strtotime($vals['create_time'])- strtotime("-12 hours");?>">剩余：<em></em></span></p>
                    <?php endif; ?>
                    <ul class="order-img">
                        <?php if(count($vals['orderGoods']['data']) > 4) :?>
                        <?php foreach ($vals['orderGoods']['data'] as $k=>$v) :?>
                                <?php if($k < 3) :?>
                                <li class="img<?php echo $k ?>">

                                    <?php if($v['goodPic']['pic'] !='') :?>
                                    <a href="<?=Yii::$app->urlManager->createUrl(["goodsdetail/index",'product_id'=>$v['product_id']])?>" target="_blank"><img src="<?=Yii::$app->params['goods_image_url'].str_replace('./upload', 'upload', $v['goodPic']['pic'])?>" title="" /></a>

                                    <?php endif;?>
                               
                               
                                <div>
                                     <?php if( $v['goodPic']['goods_name'] != '' ) :?>
                                    <p><?=$v['goodPic']['goods_name']?></p>
                                    <?php endif;?>
                                    <?php if( $v['buy_price'] != 0 ) :?>
                                    <span>￥<?=Yii::$app->formatter->asDecimal($v['buy_price'],2)?> × <?=$v['buy_number']?></span>
                                    <?php endif;?>
                                    <?php if( $v['try_coin'] != 0 ) :?>
                                        <span>试豆<?=$v['try_coin']?> × <?=$v['buy_number']?></span>
                                    <?php endif;?>
                                </div>
                                
                                </li>
                                <?php endif ;?>
                        <?php endforeach ;?>
                        <li class="see-more"><a href="<?=Yii::$app->urlManager->createUrl(["order-details/order-detail",'order_info_id'=>$vals['order_info_id']]);?>">查看全部</a></li>
                        <?php else: ?>
                          
                            <?php foreach ($vals['orderGoods']['data'] as $k=>$v) :?>
                                    <li class="img<?php echo $k ?>">

                                        <?php if($v['goodPic']['pic'] !='') :?>
                                        <a href="<?=Yii::$app->urlManager->createUrl(["goodsdetail/index",'product_id'=>$v['product_id']])?>"><img src="<?=Yii::$app->params['goods_image_url'].str_replace('./upload', 'upload', $v['goodPic']['pic'])?>" title="" /></a>

                                        <?php endif;?>
                                        
                                        <div>
                                            <?php if( $v['goodPic']['goods_name'] != '' ) :?>
                                            <p><?=$v['goodPic']['goods_name']?></p>
                                            <?php endif;?>
                                            <?php if( $v['buy_price'] != 0 ) :?>
                                                <span>￥<?=Yii::$app->formatter->asDecimal($v['buy_price'],2)?> × <?=$v['buy_number']?></span>
                                            <?php endif;?>
                                            <?php if( $v['try_coin'] != 0 ) :?>
                                                <span>试豆<?=$v['try_coin']?> × <?=$v['buy_number']?></span>
                                            <?php endif;?>

                                        </div>
                                        
                                    </li>

                            <?php endforeach ;?>
                        <?php endif ;?>
                    </ul>

					<div class="order-btn">

                        <?php if ($vals['status'] == OrderInfoDetail::$STATUS_ORDER_CREATED): ?>
                            <?php if(strtotime($vals['create_time'])- strtotime("-12 hours")>0) :?>
                            <?php if($vals['pay_status'] ==OrderInfoDetail::$PAY_STATUS_FAIL || $vals['pay_status']==OrderInfoDetail::$PAY_STATUS_WAIT) :?>
                            <a href="<?=Yii::$app->urlManager->createUrl(["order/success",'order_info_id'=>$vals['order_info_id']]);?>" class="operate-btn btn-pay" target="_blank">前往支付</a>
                            <a href="<?=Yii::$app->urlManager->createUrl(["order-details/order-detail",'order_info_id'=>$vals['order_info_id']]);?>" class="view-btn" target="_blank">查看订单</a>
                            <a href="<?=Yii::$app->urlManager->createUrl(["order-details/cancel-order",'order_info_id'=>$vals['order_info_id']]);?>" class="cancel-btn">取消订单</a>
                            <?php elseif ($vals['pay_status'] == OrderInfoDetail::$PAY_STATUS_CANCEL): ?>
                            <a href="<?=Yii::$app->urlManager->createUrl(["order-details/order-detail",'order_info_id'=>$vals['order_info_id']]);?>" class="view-btn one-btn"  target="_blank">查看订单</a>
                            <?php endif;?>
                            <?php else:?>
                            <a href="<?=Yii::$app->urlManager->createUrl(["order-details/order-detail",'order_info_id'=>$vals['order_info_id']]);?>" class="view-btn one-btn"  target="_blank">查看订单</a>
                            <?php endif;?>
                        <?php elseif ($vals['status'] == OrderInfoDetail::$STATUS_PAYED): ?>
                            <a href="<?=Yii::$app->urlManager->createUrl(["order-details/order-detail",'order_info_id'=>$vals['order_info_id']]);?>" class="view-btn one-btn"  target="_blank">查看订单</a>
                            <a href="<?=Yii::$app->urlManager->createUrl(["order-details/cancel-order",'order_info_id'=>$vals['order_info_id']]);?>" class="cancel-btn">取消订单</a>
                        <?php elseif (in_array($vals['status'], OrderInfoDetail::$STATUS_IN_KEY)): ?>
                            <a class="operate-btn btn-getgoods" href="<?=Yii::$app->urlManager->createUrl(["order-details/sure-order",'order_info_id'=>$vals['order_info_id']]);?>">确认收货</a>
                            <a href="<?=Yii::$app->urlManager->createUrl(["order-details/order-detail",'order_info_id'=>$vals['order_info_id']]);?>" class="view-btn one-btn"  target="_blank">查看订单</a>
                        <?php elseif ($vals['status'] == OrderInfoDetail::$STATUS_ORDER_OK): ?>

                            <?php if ($vals['orderGoods']['flg'] == OrderInfoDetail::$STATUS_COMMENT_NO): ?>
                            <a href="<?=Yii::$app->urlManager->createUrl(["order-details/order-detail",'order_info_id'=>$vals['order_info_id']]);?>" class="operate-btn btn-comment" target="_blank">发表评论</a>
                            <a href="<?=Yii::$app->urlManager->createUrl(["order-details/order-detail",'order_info_id'=>$vals['order_info_id']]);?>" class="view-btn  one-btn" target="_blank">查看订单</a>
                            <?php else:?>
                             <a href="<?=Yii::$app->urlManager->createUrl(["order-details/order-detail",'order_info_id'=>$vals['order_info_id']]);?>" class="view-btn  one-btn" target="_blank">查看订单</a>   
                            <?php endif;?>

                        <?php elseif ($vals['status'] == OrderInfoDetail::$STATUS_ORDER_CANCEL): ?>
                            <a href="<?=Yii::$app->urlManager->createUrl(["order-details/order-detail",'order_info_id'=>$vals['order_info_id']]);?>" class="view-btn one-btn" target="_blank">查看订单</a>
                        <?php endif; ?>

					</div>
				</div>
			</dd>

			<?php endforeach ;?>
            <?php else :?>

            <dd class="error">订单列表为空</dd>
            <?php endif;?>

		</dl>
	    
    </div>

    <!--pages-->
    <div class="page-wrap">
        <?=$page; ?>
    </div>
    <div style="height:45px;clear:both;"></div>
</div>
<!-- 主体内容 End -->

<!--侧边栏-->
<?= $this->render('@liketry/views/layouts/sidebar.php')?>
<!--js-->
<?php $this->beginBlock('js');?>
<script src="<?=Yii::getAlias('@static')?>/pc/common/js/jquery-1.12.3.min.js"></script>
<script src="<?=Yii::getAlias('@static')?>/pc/common/js/lkt.pc.js"></script>
<script src="<?=Yii::getAlias('@static')?>/pc/liketry/js/order-list.js"></script>
<script>
    var curUrl= "<?=Yii::$app->urlManager->createUrl(["order-details/order-list",'timesolt'=>''])?>";
    var mesUrl = "<?=Yii::$app->urlManager->createUrl(["order-details/express"]);?>";
</script>
<?php $this->endBlock();?>


